<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <!-- 
  面向对象语言中 this 表示当前对象的一个引用。
  JavaScript 中 this 不是固定不变的，它会随着执行环境的改变而改变。函数调用的时候确定 -->
  <script>
    let obj = {
      run: function () {
        console.log(this);
      }
    }
    // 变量赋值
    let show = obj.run
    show()

    let obj2 = {
      run: function () {
        console.log(this);
        let sum = function () {
          console.log("sum");
          console.log(this);
        }
        sum()                                                                                                                                           
      }
    }
    obj2.run()


    let obj3 = {
      run: function () {
        console.log(this);        
        let sum = function (a) {
          console.log("sum",a);
          console.log(a);
        }
        sum(this)                                                                                                                                           
      }
    }
    obj3.run()


  </script>
</body>

</html>